package com.sxm.yiwei.adapters;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.sxm.yiwei.R;
import com.sxm.yiwei.activitis.HomeSearchActivity;

/**
 * Created by KuKa on 2017/7/7.
 */

public class SearchPopAdapter extends BaseAdapter {
    Context context;
    String[] type;
    public SearchPopAdapter(Context context, String[] type) {
        this.context=context;
        this.type=type;
    }

    @Override
    public int getCount() {
        return type.length;
    }

    @Override
    public Object getItem(int position) {
        return type[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view;
        ViewHolder holder;
        if (convertView==null){
            view = View.inflate(context, R.layout.pop_item,null);
            holder = new ViewHolder();
            holder.popimg= (ImageView) view.findViewById(R.id.pop_img);
            holder.poptext= (TextView) view.findViewById(R.id.pop_text);
            view.setTag(holder);
        }else {
            view=convertView;
            holder= (ViewHolder) view.getTag();
        }
        holder.poptext.setText(type[position]);
        return view;
    }
    class ViewHolder{
        TextView poptext;
        ImageView popimg;
    }
}
